package com.ujs.edu.demo.dao;

import com.ujs.edu.demo.dataobject.BcRole;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
@Mapper
public interface BcRoleMapper {
    @Delete({
        "delete from bc_role",
        "where role_id = #{roleId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer roleId);

    @Insert({
        "insert into bc_role (role_id, member_id, ",
        "admin_id, name, description, ",
        "createtime, modifytime)",
        "values (#{roleId,jdbcType=INTEGER}, #{memberId,jdbcType=INTEGER}, ",
        "#{adminId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, ",
        "now(), now())"
    })
    int insert(BcRole record);

    @Select({
        "select",
        "role_id, member_id, admin_id, name, description, createtime, modifytime",
        "from bc_role",
        "where role_id = #{roleId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="member_id", property="memberId", jdbcType=JdbcType.INTEGER),
        @Result(column="admin_id", property="adminId", jdbcType=JdbcType.INTEGER),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modifytime", property="modifytime", jdbcType=JdbcType.TIMESTAMP)
    })
    BcRole selectByPrimaryKey(Integer roleId);

    @Select({
        "select",
        "role_id, member_id, admin_id, name, description, createtime, modifytime",
        "from bc_role"
    })
    @Results({
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="member_id", property="memberId", jdbcType=JdbcType.INTEGER),
        @Result(column="admin_id", property="adminId", jdbcType=JdbcType.INTEGER),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modifytime", property="modifytime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<BcRole> selectAll();

    @Update({
        "update bc_role",
        "set member_id = #{memberId,jdbcType=INTEGER},",
          "admin_id = #{adminId,jdbcType=INTEGER},",
          "name = #{name,jdbcType=VARCHAR},",
          "description = #{description,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "modifytime = #{modifytime,jdbcType=TIMESTAMP}",
        "where role_id = #{roleId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BcRole record);
}